﻿#ifndef _TES_MATRIX2X2_H_
#define _TES_MATRIX2X2_H_

#include <math.h>


#ifndef PAI
#define PAI 3.1415926585f
#endif

class TesVector2;
class TesMatrix3x3;
class TesMatrix4x4;

class TesMatrix2x2
{
public:
	float m2x2[4];

	void Zero();
	TesMatrix2x2();
	TesMatrix2x2(float m[4]);
	void SetMatrix(float m[4]);
	void SetMatrix(float M11, float M12, float M21, float M22); 
	TesMatrix2x2& operator = (const TesMatrix2x2& that);
	void Identity();
	TesMatrix2x2 operator + (const TesMatrix2x2& that);
	TesMatrix2x2 operator - (const TesMatrix2x2& that);
	TesMatrix2x2 operator * (const TesMatrix2x2& that);
	TesMatrix2x2 operator * (const float& K) const;
	TesMatrix2x2 operator / (const float& K); 
	float _Cofactor(int r, int c); //代数余子式
	TesMatrix2x2 _AdjoinMatrix(); //伴随矩阵
	float Determinant();  //行列式
	TesMatrix2x2 Transpose(); //转置
	TesMatrix2x2 Inverse(); //逆
	TesMatrix2x2 SetScale(float x, float y);
	TesMatrix2x2 SetRotation(float Redus);
	TesMatrix3x3 ExtendToMatrix3x3();
	TesMatrix4x4 ExtendToMatrix4x4();
	void _GetToArray(float matrix[4]);
	};

TesVector2 operator * (const TesVector2& v, const TesMatrix2x2& matrix);
TesMatrix2x2 operator * (const float& K, const TesMatrix2x2& matrix);

#define M11_2 m2x2[0]
#define M12_2 m2x2[1]
#define M21_2 m2x2[2]
#define M22_2 m2x2[3]

#endif